//
//  CYDetailHeadView.m
//  CreditAddressBook
//
//  Created by Lee on 15/5/11.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "CYDetailHeadView.h"
#import "CYDefaultRecordAO.h"
#import "UIImageView+WebCache.h"
#import "CYURL.h"

@interface CYDetailHeadView ()

@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *idCardLabel;
@property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
@end

@implementation CYDetailHeadView

- (void)setDefr:(CYDefaultRecordAO *)defr {
    if (defr.headPic) {
        [self.headImageView sd_setImageWithURL:[NSURL URLWithString:[CYUSERIMAGEBASIC stringByAppendingString:defr.headPic]] placeholderImage:[UIImage imageNamed:@"complete_profile_men_sel"]];
    }
    self.nameLabel.text = [NSString stringWithFormat:@"违约人:%@", defr.name];
    self.idCardLabel.text = [NSString stringWithFormat:@"身份证号：%@", defr.certificateNo];
    self.phoneLabel.text = [NSString stringWithFormat:@"电话号码：%@", defr.phone];
    
    if (defr.iconTag == 1) {
        [self.iconImageView setImage:[UIImage imageNamed:@"icon_yellow"]];
    }else if (defr.iconTag == 0) {
        [self.iconImageView setImage:[UIImage imageNamed:@"icon_orange"]];
    }else {
        [self.iconImageView setImage:[UIImage imageNamed:@"icon_red"]];
    }
    
    [self setupHeadPicProperty];
}

+ (instancetype)detailHeadView {
    CYDetailHeadView *view = [[[NSBundle mainBundle] loadNibNamed:@"CYDetailHeadView" owner:nil options:nil] lastObject];
    return view;
}

- (void)setFrame:(CGRect)frame {
    frame.size.height = 280;
    [super setFrame:frame];
}

/**
 *  设置头像边框
 */
- (void)setupHeadPicProperty {
//    self.headImageView.layer.cornerRadius = 44.0;
    self.headImageView.layer.masksToBounds = YES;
    self.headImageView.layer.borderColor = [CYNaviThemeColor CGColor];
    self.headImageView.layer.borderWidth = 2.5;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
